﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<link href="${ctx.resource}/css/component/coverupload.css" rel="stylesheet">

<div class="modal-dialog x-modal-dialog" style="width:600px; margin-top: 150px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb no-bottom-border clearfix">

      <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>渠道分类&nbsp;-&nbsp;修改分类</span></h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="POST" action="${ctx.host}/source-channels/${userSourceType.id}" data-validate="true">
      <input type="hidden" name="_method" value="PATCH">
      <input type="hidden" name="sourceId" value="${userSourceType.id}">
      
      <div class="modal-body">
        
        
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">分类名称</label>
          <div class="pull-left col-xs-8">
            <input type="text" name="name" value="${userSourceType.name}" class="form-control" data-validate="required">
          </div>
        </div>
        
        <c:if test="${userSourceType.parent eq '9'}">
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">所属门店</label>
          <div class="pull-left col-xs-8">
            <select name="sites" multiple class="form-control">
              <c:forEach var="relation" items="${persist.managers}">
                <option value="${relation.value.site.code}" ${userSourceType.sites.contains(relation.value.site.code) ? 'selected' : ''}>${relation.value.site.name}</option>
              </c:forEach>
            </select>
          </div>
        </div>
        </c:if>
        
      </div>

      <div class="modal-footer">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>
    </form>

  </div>

</div>

<script>
  $(function() {
    
    $('select[name="sites"]').select2({
      placeholder: '选择门店',
      minimumResultsForSearch: -1,
      allowClear: true
    });
    
  })
</script>
